#ifndef FUNCTION_H
#define FUNCTION_H

#include <QList>
#include <QString>
#include "namespace.h"
#include "type.h"

class ParameterList;

class Function : public Namespace
{
public:    
    ParameterList* parameterList() const { return m_params; }

    QString name() const { return m_name; }
    virtual QString jsName() const;

    virtual Node* getEntry( const QString& name );
    virtual Type type() { return m_type; }

protected:
    Function(const QString& name, ParameterList* params, const Type& type, const YYLTYPE& loc);

private:
    QString m_name;
    ParameterList* m_params;
    Type m_type;
};

class UserFunction : public Function
{
public:
    UserFunction(const QString& name, ParameterList* params, const QString& body, const Type& type, const YYLTYPE& loc);

    QString body() const { return m_body; }

private:
    QString m_body;
};

class Component;

class MemberFunction : public UserFunction
{
public:
    MemberFunction(const QString& name, ParameterList* params, const QString& body, const Type& type, const YYLTYPE& loc);

    Component* component() const;
};

#endif // FUNCTION_H
